<?php
namespace app\common\validate;

use think\Validate;

class UserAddressValidate extends Validate
{
    protected $rule =   [
        'id'                   => 'require|integer',
        'user_id|用户ID'       => 'require|integer',
        'address_id|地址ID'    => 'require|integer',
        'name|姓名'            => 'require|length:2,20',
        'mobile|联系方式'      => 'require|length:6,20',
        'address|地址'         => 'require|length:1,200',
        'is_default|是否默认'  => 'require|in:0,1',
    ];
    
    protected $scene = [
        /** 接口 */
        'add'      => ['user_id', 'name', 'mobile', 'address', 'is_default'],
        'set'      => ['id', 'user_id', 'name', 'mobile', 'address', 'is_default'],
        'list'     => ['user_id'],
        'show'     => ['address_id'],
        'default'  => ['address_id', 'user_id'],
    ];
}